#define _CRT_SECURE_NO_WARNINGS 1
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
const int N = 2e5 + 10;

void solve() {
	ll n, m, k; cin >> n >> m >> k;
	set<ll> a, b;
	for (int i = 1; i <= n; i++) {
		ll x; cin >> x;
		if (x >= 1 && x <= k) a.insert(x);
	}
	for (int i = 1; i <= m; i++) {
		ll x; cin >> x;
		if (x >= 1 && x <= k) b.insert(x);
	}
	if (a.size() < k / 2) {
		cout << "NO" << endl;
		return;
	}
	for (int i = 1; i <= k; i++) {
		if (!a.count(i) && !b.count(i)) {
			cout << "NO" << endl;
			return;
		}
	}
	for (int i = 1; i <= k; i++) {
		if (a.size() > k / 2 && a.count(i) && b.count(i)) {
			a.erase(i);
		}
	}
	if (a.size() != k / 2) cout << "NO" << endl;
	else cout << "YES" << endl;
}

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int t; cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}